package com.football.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.football.R;
import com.football.model.Group;

public class GroupListAdapter extends BaseAdapter {
	
	private Activity activity;
	private ArrayList<Group> groupList;
	private static LayoutInflater inflater=null;
	
	public GroupListAdapter(Activity act, ArrayList<Group> list) {
		activity = act;
		groupList = list;
		inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		return groupList.size();
	}

	@Override
	public Object getItem(int position) {
		return groupList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup vg) {
		convertView = inflater.inflate(R.layout.group, null);
		ImageView teamImg = (ImageView)convertView.findViewById(R.id.team_image);
		TextView article = (TextView)convertView.findViewById(R.id.article);
		
		Group group = groupList.get(position);
		teamImg.setImageDrawable(group.img.getDrawable());
		article.setText(group.article);
		
		return convertView;
	}

}
